#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10;
int n, a[N], k = 3;
vector<int> path;
int thgcd = 0;
vector<int> ans;

int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a % b);
}

void dfs(int begin, int pos)
{
	if(pos > k)
	{
		int ret = gcd(path[0], gcd(path[1], path[2]));
		if(thgcd < ret) 
		{
			thgcd = ret;
			ans = path;
		}
		return;
	}
	for(int i = begin; i <= n; i++)
	{
		if(a[i] <= thgcd) continue;
		else if(pos == 3 && gcd(path[0], path[1]) <= thgcd) continue;
		else
		{
			path.push_back(a[i]);
			dfs(i + 1, pos + 1);
			path.pop_back();
		}
	}
}


int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + 1 + n);
	dfs(1, 1);
	for(auto x : ans) cout << x << " ";
	return 0;
}
